/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package hxg.http.server.handler.ext;

import hxg.http.server.NamedRequestHandler;
import java.io.IOException;
import org.apache.http.Header;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.message.BasicHeader;
import org.apache.http.nio.protocol.HttpAsyncExchange;
import org.apache.http.protocol.HttpContext;

/**
 *
 * @author hxg
 */
public class TestRediectionHandler extends NamedRequestHandler {

    @Override
    public void handle(HttpRequest t, HttpAsyncExchange hae, HttpContext hc) throws HttpException, IOException {
        //System.out.println("jump to http://www.baidu.com");
        HttpResponse response = hae.getResponse();
        hc.setAttribute("test", "forJump");
        response.setStatusCode(HttpStatus.SC_MOVED_TEMPORARILY);
        Header header = new BasicHeader("location", "/login/?gw_address=192.168.0.1&gw_port=2060&gw_id=WDNR-4320-0001&mac=60:6c:66:a2:48:ce&url=http%3A//173.194.127.65/");
        //Header sh=new BasicHeader("Session-ID", "11234");request.addHeader("Session-ID", id);
        response.addHeader(header);
        //response.addHeader("Session-ID","1asfdajslkdfjlaks");
        hae.submitResponse();
    }

}
